/**
 * Created by Demon-pro on 2015/7/27.
 */
var BlowerDes = function (){

    var saveValue = function(){
        var save = function(thisDom){
            $.ajax({
                url:basePath + "blower/design/saveValue",
                type:"post",
                dataType:"json",
                data: thisDom.attr("id") + "=" + thisDom.val() + "&paramName=" + thisDom.attr("id") + "&paramValue=" + thisDom.val()
            });
        };
        $("input").on('blur',function(){
            var $this = $(this);
            validate.init($this)
            if(validate.isNotNumber($this.val())){
                validate.invalid();
                return;
            }else{
                save($this);
                validate.valid();
            }
        });
        $("select").on('change', function () {
            validate.init($(this));
            save($(this));
            validate.valid();
        });
    };

    var calculateInit = function() {
        $.post(basePath + "blower/design/calculateInit",function() {});
    };

    var getRecover = function(){
        $.get(basePath + "blower/design/getRecover",function(data){
            $("input").autoInject({
                data:data,
                mode:"id"
            });
            Metronic.unblockUI();
        }).done(calculateInit());

    }
    return {
        init:function (){
            Metronic.blockUI({
                boxed:true,
                message:"数据计算中..."
            });
            saveValue();
            getRecover();

        }
    }
}();